Skip to content

London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | stretch#939

Open
mohsenzamanist wants to merge 2 commits intoCodeYourFuture:mainfrom
mohsenzamanist:coursework/sprint-3-stretch
Open

London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | stretch#939
mohsenzamanist wants to merge 2 commits intoCodeYourFuture:mainfrom
mohsenzamanist:coursework/sprint-3-stretch

Conversation

@mohsenzamanist
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Comelete exercises in directory called 4-stretch

Questions

@github-actions

This comment has been minimized.

@mohsenzamanist mohsenzamanist changed the title London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | stretch London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | Stretch Feb 9, 2026
@mohsenzamanist mohsenzamanist changed the title London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | Stretch London | ITP-Jan-26 | Mohsen Zamani | Sprint 3 | stretch Feb 9, 2026
@mohsenzamanist mohsenzamanist added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 9, 2026
Comment on lines 10 to 12
!cardNumArray.every(
(num) => num.charCodeAt(0) >= 48 && num.charCodeAt(0) <= 57
)
Copy link
Contributor

@cjyuan cjyuan Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We could also check if num is a digit as num >= '0' && num <= '9'.

Comment on lines 17 to 21
const count = cardNumArray.reduce((acc, curr) => {
acc[curr] = acc[curr] ? acc[curr] + 1 : 1;
return acc;
}, {});
if (Object.keys(count).length < 2) return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works.
Challenge: Implement a simpler and more efficient way to check distinct digit count with Set.

@@ -1,6 +1,12 @@
const previousPasswords = ["5B43n21"];
function passwordValidator(password) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we design the function as

function passwordValidator(password, previousPasswords=[]) {
  ...
}

we could let the caller specify what the previous passwords are.

@@ -1,6 +1,12 @@
const previousPasswords = ["5B43n21"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An invalid password is not a good candidate for a previous password.

}
); No newline at end of file
// Arrange
const password = "A1b2";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function can return false for multiple reasons.
To test a specific reason, choose an input that satisfies all other conditions except the one you're targeting. This way, if the function returns false, you can confidently attribute it to that specific condition.

For example, the function might return false for "A1b2" not only because it is fewer than 5 characters, but also because it lacks a special letter.
As a result, we can't be certain that the function correctly handles the case of passwords shorter than 5 characters, since multiple conditions are being violated simultaneously.

Comment on lines 36 to 52
test("password contains at least one uppercase English letter", () => {
// Arrange
const password = "1a2345";
// Act
const result = isValidPassword(password);
// Assert
expect(result).toEqual(false);
});

test("password contains at least one uppercase English letter", () => {
// Arrange
const password = "1B2345";
// Act
const result = isValidPassword(password);
// Assert
expect(result).toEqual(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • These two tests have the same description but they are testing two different things.

Copy link
Contributor

@cjyuan cjyuan Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the test descriptions more detailed and descriptive? That way, if a test fails, the person implementing the function can quickly understand what went wrong and why.

Right now, for example, "password contains at least one number (0-9)" does not quite indicate what the test is testing. (Did you mean to say "not containing")

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 17, 2026
@mohsenzamanist mohsenzamanist added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants